home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Feb 90 / MacApp.Tech$ 2⁄2⁄90 / 0611-Callbacks & MacApp D-Feb90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.8 KB  |  66 lines  |  [TEXT/GEOL]

  1. Item    7278104                         2-Feb-90        13:38PST
  2.  
  3. From:   STATTENFIELD                    Stattenfield, Keith
  4.  
  5. To:     D5369                           Mgmt Sys Des, Chuck McMath,PRT
  6.         MADDEN                          Madden, Sue
  7.  
  8. cc:     MACAPP.TECH$                    MacApp Technical
  9.  
  10. Sub:    Callbacks & MacApp Debugger
  11.  
  12. Chuck & others,
  13.  
  14.     The problem with your callback routines is that the Pascal compiler
  15. is"automagically" inserting calls to a routine called "%_BP" and "%_EP" at the
  16. beginning and end of every procedure.  It does this because MacApp source code
  17. uses the {$D++} command (an undocumented variant of {$D+}).
  18.  
  19.     Below is a sample of a completion routine from a program of my own which
  20. works.
  21.  
  22. {$PUSH} {$S Main} {$D+}
  23.  
  24. FUNCTION GetMyHConn : ConnHandle; INLINE $2028, $FFFC; { MOVE.L -4(A0),D0 }
  25. PROCEDURE SaveRegs;  INLINE $48E7, $0F0C;  { MOVEM.L D4-D7/A4/A5,-(A7) }
  26. PROCEDURE RestoreRegs;  INLINE $4CDF, $30F0;   { MOVEM.L (A7)+,D4-D7/A4/A5 }
  27.  
  28. PROCEDURE CommStuffCompletionRoutine2 (hConn : ConnHandle);
  29.    VAR
  30.    CommunicationObject : TCommunication;
  31.  
  32.    BEGIN
  33.  
  34.    CommunicationObject := TCommunication( CMGetRefCon(hConn));
  35.    CommunicationObject.fAsyncState := CSDone;
  36.  
  37. {$IFC qCSUseStatusFile}
  38.    CommunicationObject.fTickWhenWriteCompleted := TickCount;
  39. {$ENDC qCSUseStatusFile}
  40.  
  41.    END;
  42.  
  43. (* Do some wierd stuff to keep the compiler from optimizing this
  44.     into non-working code *)
  45. PROCEDURE CommStuffCompletionRoutine (hConn : ConnHandle);
  46. BEGIN
  47.  
  48.    SaveRegs;
  49.  
  50.    CommStuffCompletionRoutine2(hConn);
  51.  
  52.    RestoreRegs;
  53.  
  54. END;
  55.  
  56.  
  57. {$POP}
  58.  
  59.  
  60. Put this at the very end of your source code -- I don't bother to turn {$D++}
  61. back on before the {$POP}, and {$POP} doesn't restore the setting.
  62.  
  63. -Keith Stattenfield
  64. Apple Computer, Inc.
  65.  
  66.